<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 5 Transitional//EN">
<%@ page pageEncoding="UTF-8" %>
<%@ page import="jp.co.technotree.apl.api.common.Message" %>
<%@ page import="jp.co.technotree.apl.cmd.spare.Spa3000Bean;" %>
<jsp:useBean id="formBean" class="jp.co.technotree.apl.cmd.spare.Spa3000Bean" scope="request" />
<%

	Spa3000Bean.Record[] recordList = formBean.getRecordList();
%>
<html>
<head>


<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<meta name="apple-mobile-web-app-capable" content="yes"/>
<!-- 数字を電話番号にさせない -->
<meta name="format-detection" content="telephone=no"/>
<link rel='stylesheet' type='text/css' href='../../common/css/spare/spa3000.css' >
<script src="../../common/js/spare/spa3000.js" type="text/javascript"></script>

<!-- ITEM-DROPDOWN START -->
<link rel="stylesheet" href="../../common/js/dropdown/dropdown.css" type="text/css">
<script src="../../common/js/dropdown/dropdown.js" type="text/javascript"></script>
<!-- ITEM-DROPDOWN END -->

<!--ポップアップ用-->
<link rel='stylesheet' type='text/css' href='../../common/css/popUp.css' >
<script type='text/javascript' src='../../common/js/popUp.js'></script>

<style type="text/css">
	.menu-img-rlist2000 {
		background:		url(../../common/img/menu/line.png) no-repeat;
	}

	.mainBtn {
		width: 150px;
		font-size:20px;
	}

	.div-wid {
		-webkit-overflow-scrolling:touch;
		height:415px;
		overflow:auto;
	}
	
	.TblField1{
		width:20px;
	}
	.TblField2{
		width:120px;
	}
	.TblField3{
		width:150px;
	}
	.TblField4{
		width:150px;
	}
	.TblField5{
		width:100px;
	}
	.TblField6{
		width:60px;
	}
	.TblField7{
		width:40px;
	}
	.TblField8{
		width:100px;
	}
	.TblField9{
		width:40px;
	}
	.TblField10{
		width:100px;
	}
</style>



<script language='javascript'>

//画面固定
//document.addEventListener('touchmove', function (e) { e.preventDefault(); }, false);

function onInit(){
	<%if("1".equals(formBean.getErrMsgFlg())){%>
		alert_Custom("<%=Message.getMessage("WRN01050")%>");
	<%}%>
	//-------------------------------------------------------------------------
	//<!-- ITEM-DROPDOWN START -->
	var panel = document.getElementById("dropdown-panel");
	var input = document.getElementById("addTable");
	
	var targetList = getElementsByClassName(input,"input","item",true);
	
	dropdown = new CItemDropDownList(targetList,panel,"drop-contents");
	dropdown.setKeyUpEvent(text_onKeyUp);
	dropdown.setSelectEvent(list_onSelect);
	
	//
	dropdown.serverURL="../itm1099/itm1099";
	//<!-- ITEM-DROPDOWN END -->
	//-------------------------------------------------------------------------
	
}


//通常検索
function formSubmit() {
	var frm = document.main;
	//ソートクリア-----------------------
	frm.columnSortText.value = "";
	frm.columnSortSelect.value = "";
	//-----------------------------------
	frm.cmd.value = "cmd01";
	frm.submitFlag.value = "1";
	frm.submit();
}
//ソート
function changeColumnSort(key) {
	var formName = "main";
	var frm = document[formName];
	frm.columnSortSelect.value = key;
	frm.submitFlag.value = "1";
	
	frm.cmd.value = "cmd01";
	frm.submitFlag.value = "1";
	frm.submit();
}

//-------------------------------------------------------------------------
//<!-- ポップアップ START -->

//パップアップ解除
function back(){
	document.getElementById("opAlertBtn").style.display = "none";
	document.getElementById("opAlert").style.display = "none";
	document.getElementById("opAlertButton").style.display = "none";
	document.getElementById("opAlertTop").style.display = "none";
	document.getElementById("allbackgr").style.display = "none";
}

//<!-- ポップアップ END -->
//-------------------------------------------------------------------------

//-------------------------------------------------------------------------
//<!-- ITEM-DROPDOWN START -->
var dropdown = null;

var inputDateTime = null;
var timerId = null;
var eventSrc={};
function text_onKeyUp(object,sender,evt){
	var value = sender.value;
	eventSrc.object = object;
	eventSrc.sender = sender;
	eventSrc.evt = evt;
	inputDateTime = new Date();
	//-----------------------------------------------
	//品番自動ハイフン「-」を付ける
	var chkLen=5;
	if(event.keyCode != 0008){
		//指定の桁以上ならスタート
		if(value.length>=chkLen){
			var hikaku = value.substring(chkLen, chkLen+1);
			if(hikaku != "-"){
				var frontValue = value.substring(0, chkLen);
				var backValue  = value.substring(chkLen, value.length);
				sender.value=frontValue+"-"+backValue;
			}
		}
	}
	//小文字を大文字へ
	sender.value = sender.value.toUpperCase();
	value = sender.value;
	//-----------------------------------------------
	if ( value.length >= <%=formBean.getGohoKensu() %> ){
		if ( evt.keyCode == 37 || evt.keyCode == 39 ){
			
		}else{
			if ( timerId == null ){
				// 連続送信防止
				timerId = window.setTimeout(function(){text_onTimeOut(object,sender,evt);},500);
			}
		}
	}
}

/**
* 一定時間入力が止まった場合に動作
*/
function text_onTimeOut(object,sender,evt){
	var nowDateTime = new Date();
	var lngTime = (nowDateTime.getTime()-inputDateTime.getTime());
	if ( lngTime >= 1000 ){
		timerId = null;
		xmlRequest(object,sender,evt);
	}else{
		timerId = window.setTimeout(function(){text_onTimeOut(eventSrc.object,eventSrc.sender,eventSrc.evt);},500);
	}
}

/**
* XML要求処理
*/
function xmlRequest(object,sender,evt){
	//alert(evt.keyCode);
	var table = document.getElementById("drop-contents");
	table.innerHTML="";
	
	var top = calculateOffsetTop(sender);
	var left = calculateOffsetLeft(sender);
	var height = sender.offsetHeight;
	var panel = document.getElementById("dropdown-panel");
	panel.style.top=top+height+"px";
	panel.style.left=left+"px";
	panel.style.display="block";
	
	var param="itemCd="+sender.value+"&rsvDiv=0"+"&tempFlg=0"+"&delDiv=0";
	
	try {
		var frm = document.main;
		var objs = frm["invCate"];
		if (objs[1].checked == true){
			//仮入出庫
			param += "&afterProc=1";
		}
	} catch (e) {
		
	}

	object.doXmlRequest(object,sender,param);
}


/**
* リスト選択時コールバック処理
*/
function list_onSelect(object,sender,json){
	var panel = document.getElementById("dropdown-panel");
	panel.style.display="none";
	sender.focus();
	
	//----------
	var name=sender.name;
	var idx=name.substring(name.indexOf("[")+1,name.length-1);
	
	document.getElementById("findItemNo").value=json.itemcd;
	
}


function getElementsByClassName(parent,tagName,className,fullMatch){
	var i=0,j=0;
	var result = [], cnt = 0;
	var list = parent.getElementsByTagName(tagName);
	for ( i=0; i<list.length; i++ ){
		var name = list[i].className;
		if ( name ){
			var nameList = name.split(' ');
			for ( j=0; j<nameList.length; j++ ){
				if ( fullMatch ){
					if ( nameList[j] == className ){
						result[cnt++] = list[i];
					}
				}else{
					if ( nameList[j].indexOf(className) != -1 ){
						result[cnt++] = list[i];
					}
				}
			}
		}
	}
	return result;
}
function closeBtn(){
	var panel = document.getElementById("dropdown-panel");
	panel.style.display="none";
} 
//----------------------------------------------------------------------


//選択ボタンからの遷移
function selectPageJump(nextPage,itemNo,itemNm,model,rackNo,picfileNm){
	document.getElementById('selectFlag').value = "1";
	document.getElementById('itemNo_hid').value = itemNo;
	document.getElementById('itemNm_hid').value = itemNm;
	document.getElementById('model_hid').value = model;
	document.getElementById('rackNo_hid').value = rackNo;
	document.getElementById('picfileNm_hid').value = picfileNm;
	nextPageJump("back");
}

function nextPageJump(nextPage){
	mainForm = document.getElementById("F1");
	document.getElementById("nextPage").value = nextPage;
	mainForm.submit();
}

//クリアボタン
function findClearBtn(){
	var frm = document.main;
	//ソートクリア-----------------------
	frm.columnSortText.value = "";
	frm.columnSortSelect.value = "";
	//-----------------------------------
	frm.cmd.value = "cmd01";
	frm.findItemNo.value = "";
	frm.findItemNm.value = "";
	frm.findModel.value = "";
	frm.submit();
}
</script>


</head>

<body onLoad="onInit()">
<form name="main" id="F1" action="./spa3000" method="post" class="frmMain" onsubmit="return false;">
<input type="hidden" name="cmd" value="cmd01">
<input type="hidden" name="selectFlag" id="selectFlag" value="">
<input type="hidden" name="submitFlag" value="0">
<input type="hidden" id="nextPage" name="nextPage" value="">
<input type="hidden" id="dataId" name="dataId" value="">
<input type="hidden" id=displayCate name="displayCate" value="<%=formBean.getDisplayCate()%>">
<!-- カラムソート -->
<input type="hidden" name="columnSortText" value="<%=formBean.getColumnSortText()%>">
<input type="hidden" name="columnSortSelect" value="">


<!-- 画面引き継ぎ用 -->
<input type="hidden" id=itemNo_hid name="itemNo_hid" value="<%=formBean.getItemNo_hid()%>">
<input type="hidden" id="itemNm_hid" name="itemNm_hid" value="<%=formBean.getItemNm_hid()%>">
<input type="hidden" id="model_hid" name="model_hid" value="<%=formBean.getModel_hid()%>">
<input type="hidden" id="rackNo_hid" name="rackNo_hid" value="<%=formBean.getRackNo_hid()%>">
<input type="hidden" id="delvDiv_hid" name="delvDiv_hid" value="<%=formBean.getDelvDiv_hid()%>">
<input type="hidden" id="delvDt_hid" name="delvDt_hid" value="<%=formBean.getDelvDt_hid()%>">
<input type="hidden" id="delvNewNum_hid" name="delvNewNum_hid" value="<%=formBean.getDelvNewNum_hid()%>">
<input type="hidden" id="delvUsedNum_hid" name="delvUsedNum_hid" value="<%=formBean.getDelvUsedNum_hid()%>">
<input type="hidden" id="delvSite_hid" name="delvSite_hid" value="<%=formBean.getDelvSite_hid()%>">
<input type="hidden" id="delvSiteUsr_hid" name="delvSiteUsr_hid" value="<%=formBean.getDelvSiteUsr_hid()%>">
<input type="hidden" id="delvReasonTxt_hid" name="delvReasonTxt_hid" value="<%=formBean.getDelvReasonTxt_hid()%>">
<input type="hidden" id="delvUsr_hid" name="delvUsr_hid" value="<%=formBean.getDelvUsr_hid()%>">
<input type="hidden" id="delvUsrList_hid" name="delvUsrList_hid" value="<%=formBean.getDelvUsrList_hid()%>">
<input type="hidden" id="picfileNm_hid" name="picfileNm_hid" value="<%=formBean.getPicfileNm_hid()%>">
<input type="hidden" id="updateDt_hid" name="updateDt_hid" value="<%=formBean.getUpdateDt_hid() %>">
<input type="hidden" id="updateDt_stock" name="updateDt_stock" value="<%=formBean.getUpdateDt_stock() %>">

<table style="">
	<!--HEADER TITLE START -->
	<tr style = "background-color:#e1e1e1;  font-weight: bold;  border-bottom:1px solid #e1e1e1; background: -webkit-gradient(linear, left top, left bottom, from(#e1e1e1), to(#ffffff));　 ">
		<td colspan="2" class ="header_tbl" style = "font-size:22px; height:40px;"  align = "left">
			　予備品管理システム (<%=formBean.kojou%>)　　　
			<span style="font-size:30px; text-shadow:2px 2px #666; 	color:#aaa;">予備品選択画面</span>
		</td>
	</tr>
	<!--HEADER TITLE END -->

	<!--予備品選択画面　START  -->
	<!-- 検索部  -->
	<tr style="height:628px;vertical-align:top;">
		<td class="right" >
			<!-- <div class="mainLine" id = "mainLine" style="display:inline; " ></div> -->

	
			<table class="searchTbl" id="addTable" name="addTable" >
				<tr>
					<td>
						予備品：直結看板予備品
					</td>
					<td colspan="3">
					</td>
					<td>
						<input onclick="findClearBtn();" type="button" value="クリア" class="button">
					</td>
				</tr>
				<tr>
					<td >
						Y品番：
						<input id="findItemNo" type="text" class="item inputStyle" style="width:120px;" name="findItemNo" value="<%=formBean.getFindItemNo()%>" maxlength="11">
					</td>
					<td>
						品名：
						<input id="findItemNm" type="text" class="inputStyle" style="width:170px;" name="findItemNm" value="<%=formBean.getFindItemNm()%>" maxlength="100">
					</td>
					<td>
						型式：
						<input id="findModel" type="text" class="inputStyle" style="width:170px;" name="findModel" value="<%=formBean.getFindModel()%>" maxlength="100">
					</td>
					<td style="width:120px;">
						<input onclick="formSubmit();" type="button" value="検索" class="button">
					</td>
					<td style="width:120px;">
						<input onclick="nextPageJump('back');" type="button" value="戻る" class="button">
					</td>
				</tr>
			</table>
			
			<br>
			<hr width="95%" size="1" color="#000000">
			<%if(recordList.length >= 50){%>
				&nbsp;&nbsp;&nbsp;
				<span style="color:blue;"><%=Message.getMessage("INF00050")%></span>
			<%}else{%>
				<br>
			<%}%>
			
<%if("1".equals(formBean.getSubmitFlag())){%>
			<!-- 一覧部  -->
			<table class="listTbl" >
				<!--人作業登録 -->
				<tr>
					<th class="TblField1">&nbsp;</th>
					<th class="TblField2" onclick="changeColumnSort('item_no');">Y品番	<%=formBean.getSort().getSortText("item_no")%></th>
					<th class="TblField3" onclick="changeColumnSort('srp.item_nm');">品名	<%=formBean.getSort().getSortText("srp.item_nm")%></th>
					<th class="TblField4" onclick="changeColumnSort('srp.model');">型式	<%=formBean.getSort().getSortText("srp.model")%></th>
					<th class="TblField5" onclick="changeColumnSort('supplier_nm');">仕入先	<%=formBean.getSort().getSortText("supplier_nm")%></th>
					<th class="TblField6" onclick="changeColumnSort('srp.unit_price');">単価	<%=formBean.getSort().getSortText("srp.unit_price")%></th>
					<th class="TblField7" onclick="changeColumnSort('srp.lead_tm');">L/T	<%=formBean.getSort().getSortText("srp.lead_tm")%></th>
					<th class="TblField8" onclick="changeColumnSort('srp.rack_no');">棚番	<%=formBean.getSort().getSortText("srp.rack_no")%></th>
					<th class="TblField9" onclick="changeColumnSort('srp.basic_stock');">基準	<%=formBean.getSort().getSortText("srp.basic_stock")%></th>
					<th class="TblField10">&nbsp;</th>
				</tr>
				
			</table>
			<div class="div-wid ">
			<table class="listTbl" >
<%
		if ( recordList!=null) {
			if ( recordList.length == 0 ){
%>			
			<tr height="120px">
				<td colspan="10">データが存在しません。</td>
			</tr>
<%			
			}
			for (int i=0; i<recordList.length; i++) {
				Spa3000Bean.Record record=recordList[i];
%>
				<tr class="<%=record.disStyle%>">
					<td class="TblField1" onclick="opInf.mhClick(this);">
						<%=i+1%>
						<input type="hidden" name="lblField1" value="<%=record.itemNo%>" >
						<input type="hidden" name="lblField2" value="<%=record.itemNm%>" >
						<input type="hidden" name="lblField3" value="<%=record.model%>" >
						<input type="hidden" name="lblField4" value="<%=record.supplierNm%>">
						<input type="hidden" name="lblField5" value="<%=record.unitPrice%>" >
						<input type="hidden" name="lblField6" value="<%=record.leadTm%>" >
						<input type="hidden" name="lblField7" value="<%=record.rackNo%>" >
						<input type="hidden" name="lblField8" value="<%=record.basicStock%>" >
					</td>
					<td class="TblField2" onclick="opInf.mhClick(this);"><%=record.itemNo%></td>
					<td class="TblField3" onclick="opInf.mhClick(this);"><%=record.itemNm%></td>
					<td class="TblField4" onclick="opInf.mhClick(this);"><%=record.model%></td>
					<td class="TblField5" onclick="opInf.mhClick(this);"><%=record.supplierNm%></td>
					<td class="TblField6 txtRight" onclick="opInf.mhClick(this);">&yen;<%=record.unitPrice%></td>
					<td class="TblField7 txtRight" onclick="opInf.mhClick(this);"><%=record.leadTm%></td>
					<td class="TblField8" onclick="opInf.mhClick(this);"><%=record.rackNo%></td>
					<td class="TblField9 txtRight" onclick="opInf.mhClick(this);"><%=record.basicStock%></td>
					<td class="TblField10"><input type="button" value="選択" class="button" onclick="selectPageJump('back','<%=record.itemNo%>','<%=record.itemNm%>','<%=record.model%>','<%=record.rackNo%>','<%=record.picfileNm%>')"></td>
				</tr>
<% 	
			}
		}
%>
			</table>
			</div>
<%}%>
				
			<!--ログインMAIN画面　END  -->
		</td>
	</tr>
</table>
	<div class='footer' align='right' style="font-size:35px; background-image: url(../../common/img/toyotaB.png); background-repeat: no-repeat; align:top;" ></div> 


	<!-- 詳細用 -->
	<div class="opBoardBtn" id = "opBoardBtn" style="display:none;" ></div>
	<div class="opBoardInf" id = "opBoardInf" style="display:none;" ></div>
	<div class="opBoardButtom" id = "opBoardButtom" style="display:none;"></div>
	<div class="opBoardTop" id = "opBoardTop" style="display:none; font-size:22px;">　詳細情報　</div>
	<div class="opBoard" id = "opBoard"  style="display:none; overflow: scroll;"></div>
	<div class="mhBoard" id = "mhBoard" style="display:none;"></div>

<!-- ITEM-DROPDOWN START -->
<div class="dropdown-panel" id="dropdown-panel">
	<div class="dropdown-panel-in">
		<div class="header">
			<div style="float:left;width:110px;height:20px;">
				<table border=0>
					<tr>
						<td style="width:110px;height:20px;">品番</td>
					</tr>
				</table>
			</div>
			<div style="float:right;width:40px;text-align:right;">
				<button class="closebtn" type="button" onClick="closeBtn();" style="width:18px;height:17px; padding:0px;">
					<img src="../../common/js/dropdown/close.gif" alt="閉じる">
				</button>
			</div>
		</div>
		<div class="drop-contents" id="drop-contents">
		</div>
		<div class="footer"></div>
	</div>
</div>
<!-- ITEM-DROPDOWN END -->

	<!--警告 ポップアップ---------------------------------------------------------------------------- -->
	<div id="allbackgr" class="allbackgr" style="display:none;"></div>
	<div class="opAlertBtn" id = "opAlertBtn" style="display:none;" ></div>
	<div class="opAlertButton" id = "opAlertButton" style="display:none;" ></div>
	<div class="opAlertTop" id = "opAlertTop" style="display:none; font-size:22px;">　予備品管理システム　</div>
	<div class="opAlert" id = "opAlert" style="display:none;"></div>
	<!-- -------------------------------------------------------------------------------------------- -->
	
</form>
</body>
</html>
